package com.jintoufs.service.travelagency.impl;

import com.jintoufs.dao.QueryFilters;
import com.jintoufs.dao.travelagency.PoiDAO;
import com.jintoufs.dao.travelagency.TravelAgencyMapper;
import com.jintoufs.domain.customer.Customer;
import com.jintoufs.domain.shop.Shop;
import com.jintoufs.domain.shop.ShopManager;
import com.jintoufs.domain.travelagency.Poi;
import com.jintoufs.domain.travelagency.TravelAgency;
import com.jintoufs.service.shop.ShopManagerService;
import com.jintoufs.service.shop.ShopService;
import com.jintoufs.service.travelagency.PoiService;
import com.jintoufs.service.travelagency.TravelAgencyService;
import com.jintoufs.uuid.SnowflakeIdWorker;
import org.apache.commons.lang.StringUtils;
import org.cosmos.modules.exception.ServiceException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author : zhenghq
 * @Despription :
 * @Date 2018/1/25 15:13
 * @Modified by
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class PoiServiceImpl implements PoiService {

    @Autowired
    private PoiDAO poiDAO;

    @Resource
    private SnowflakeIdWorker snowflakeIdWorker;

    @Override
    public void insert(Poi poi) throws ServiceException {
        poi.setId(getUUID());
        poiDAO.insert(poi);

    }

    @Override
    public void update(Poi poi) throws ServiceException {
        poiDAO.updateByPrimaryKeyWithBLOBs(poi);
    }

    @Override
    public void delete(String id) throws ServiceException {
        poiDAO.deleteByPrimaryKey(id);
    }

    @Override
    public Poi getByPrimaryKey(String id){
        return poiDAO.selectByPrimaryKey(id);
    }

    @Override
    public List<Map> getByFilter(QueryFilters filters) {
        return poiDAO.getByFilter(filters);
    }

    @Override
    public List<Map<String,Object>> getByParams(Map<String,Object> map) {
        return poiDAO.getByParams(map);
    }


    private String getUUID(){
        return String.valueOf(snowflakeIdWorker.nextId());
    }
}
